home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: i = atoi(NULL);
- Date: Thu, 25 Jan 96 14:15:57 GMT
- Organization: none
- Message-ID: <822579357snz@genesis.demon.co.uk>
- References: <DKwCsG.IGD@cs.openu.ac.il> <96009.103802DSEAMA41@portland.caps.maine.edu> <30F7F466.F43@imsisoft.com> <DLnJpF.ApL@cs.openu.ac.il>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <DLnJpF.ApL@cs.openu.ac.il>
- shimoco@mail.tlm.openu.ac.il "Shimon Cohen" writes:
-
- >Thats right !
- >I called atoi like this:
- >i = atoi (strtok (input_str, ",");
- >My compiler (BC4.0) docs says: "If no conversion could be performed,
- >zero is returned." . I used this fact and it works fine. but not under
- >the unix machine of my teacher :-(
-
- This hinges on what is meant by "If no conversion could be performed".
- What it actually means is if the contents of the string passed to
- atoi() is not recognised as a number e.g. atoi("A1234") would return 0. You
- are still required to pass atoi() a pointer to a valid string, a null
- pointer doesn't qualify. Your system probably accepts it because it
- doesn't support the hardware protection required to trap an invalid
- null pointer dereference whereas the Unix system does.
-
- Thank the Unix system - it helped you to identify and correct a bug in your
- program.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-